package common.components
{
	import mx.controls.Image;
	import mx.core.BitmapAsset;
	import mx.events.FlexEvent;
	
	public class SmoothImage extends Image {
	
		public function SmoothImage() 
		{
			super();
			addEventListener(FlexEvent.CREATION_COMPLETE, smoothImage);
			addEventListener(FlexEvent.UPDATE_COMPLETE, smoothImage);
		}
	
		private function smoothImage(event:FlexEvent):void
		{
			var bitmap:BitmapAsset = ((event.target as Image).content as BitmapAsset);
			if (bitmap != null) {
				bitmap.smoothing = true; //this is for embedded images
			} else {
				try
				{
					if (event.target.content != null) {
						event.target.content.smoothing = true; //this is for non-embedded (loaded) images
					}
				}
				catch(error:Error)
				{
					trace("bitmap smoothing error:"+error.message);
				}
			}
		}
	
	} // end class
}